package com.eva.client.api.cms;

import com.eva.cms.biz.category.CmsCategoryBiz;
import com.eva.cms.biz.category.vo.CmsCategoryNodeVO;
import com.eva.framework.common.api.BaseController;
import com.eva.framework.common.model.ApiResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@Api(tags = "栏目相关接口")
@RestController
@RequestMapping("/category")
public class CmsCategoryController extends BaseController {

    @Resource
    private CmsCategoryBiz cmsCategoryBiz;

    @ApiOperation("查询栏目树")
    @GetMapping("/tree")
    public ApiResponse<List<CmsCategoryNodeVO>> findTree() {
        return ApiResponse.success(cmsCategoryBiz.findTree(Boolean.FALSE));
    }

    @ApiOperation("查询子栏目树")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "parentCategoryUid", value = "父栏目唯一标识", dataType = "String", required = true)
    })
    @GetMapping("/{parentCategoryUid}/tree")
    public ApiResponse<List<CmsCategoryNodeVO>> findSubTree(@PathVariable String parentCategoryUid) {
        return ApiResponse.success(cmsCategoryBiz.findSubTree(parentCategoryUid, Boolean.FALSE));
    }
}
